<?php
require_once ('admin.php');
global $current_user;
$error = array();
$ok = 1;
$sucessfull = 0;
/*
 * Submit
 */
if (isset($_REQUEST['publish_product'])) {
    if ($_REQUEST['name'] == "") {
        $error['name'] = "Name can not be blank";
        $ok = 0;
    }

    if ($ok == 1) {
        Category::update($current_user->ID, $_REQUEST['name'], DealFlight::FLIGHT);
        $sucessfull = 1;
    }
}

if (isset($_GET['i'])) {
    $id = $_GET['i'];
    $catInfo = Category::getInfo($id);
    if ($catInfo) {
        
    } else {
        wp_redirect('404.php');
    }
} else {
    wp_redirect('404.php');
}
?>    
<?php include_once ('./admin-header.php'); ?>
<link rel="stylesheet" type="text/css" href="css/tuan.css"/>
<link rel="stylesheet" type="text/css" href="css/tham.css"/>
<div class="wrap nosubsub">
    <h2>Update Flight Category<?php
if (!empty($_REQUEST['s']))
    printf('<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html(wp_unslash($_REQUEST['s'])));
?>
    </h2>

    <form id="posts-filter" method="post">     
        <hr>
<?php
if ($sucessfull == 1) {
    ?>
            <div class="div_sucess">You have updated successfully</div>
            <?php
        }
        ?>
        <div style="width:100%; background:#FDFDFD">
            <table width="707"  height="77" cellspacing="0" >
                <tr>
                    <th width="138" valign="top"  scope="row" align="left">
                        <label for="siteupdates">
                            <p class="labelp"><?php _e('Name') ?> (*)</p>  
                        </label>
                    </th>
                    <td width="563"  valign="top">
                        <div style="margin-top:10px;">:  			    
                            <input  style="width:80%; height:30px;" name="name" type="text" id="name"   
                                    value="<?Php echo $catInfo[0]->name ?>"  class="regular-text"> 
                            <span class="errorclass"><Br/><?php echo $error['name']; ?></span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th valign="top"  scope="row" align="left">&nbsp;</th>
                    <td  valign="top"><div style="margin-top:10px; margin-left:5px;">
                            <input type="submit" name="publish_product" id="publish_product" 
                                   class="button button-primary button-large" value="Update" accesskey="p"></div>
                    </td>
                </tr>
            </table>
        </div>
    </form>

</div>



<?php
include('./admin-footer.php');
?>

